Preserve query components in PRM resource URLs#3066
Open
mayankbohradev wants to merge 1 commit into
Open
Conversation
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Fixes query-bearing protected-resource identifiers in the OAuth protected resource metadata path.
When a server URL includes a query component, for example
https://api.example.com/mcp?tenant=a, the SDK now:Closes #3065.
Why
RFC 9728's well-known URL construction inserts
/.well-known/oauth-protected-resourcebefore the resource path and/or query. Dropping the query collapses query-routed resource identifiers, so a deployment using?tenant=aand?tenant=bcan publish or accept the wrong protected resource metadata.Tests
uv run --frozen pytest tests/client/test_auth.py::TestSEP985Discovery::test_prm_discovery_preserves_server_url_query_component tests/client/test_auth.py::test_validate_resource_rejects_mismatched_query_component tests/server/auth/test_protected_resource.py::test_metadata_url_construction_preserves_query_component tests/shared/test_auth_utils.py::test_check_resource_allowed_rejects_different_queries -quv run --frozen pytest tests/client/test_auth.py tests/shared/test_auth_utils.py tests/server/auth/test_protected_resource.py tests/interaction/auth/test_discovery.py -quv run --frozen ruff format src/mcp/server/auth/routes.py src/mcp/client/auth/utils.py src/mcp/shared/auth_utils.py tests/server/auth/test_protected_resource.py tests/client/test_auth.py tests/shared/test_auth_utils.pyuv run --frozen ruff check src/mcp/server/auth/routes.py src/mcp/client/auth/utils.py src/mcp/shared/auth_utils.py tests/server/auth/test_protected_resource.py tests/client/test_auth.py tests/shared/test_auth_utils.pyuv run --frozen pyright src/mcp/server/auth/routes.py src/mcp/client/auth/utils.py src/mcp/shared/auth_utils.py tests/server/auth/test_protected_resource.py tests/client/test_auth.py tests/shared/test_auth_utils.py./scripts/test— 5293 passed, 9 skipped, 1 xfailed; coverage 100%; strict-no-cover cleanNote: full
uv run --frozen pyrightcurrently reports two errors in unrelatedtests/transports/stdio/test_lifecycle.pyaroundos.waitidtyping on this machine. The changed files pass scoped pyright as listed above.AI-assisted (Claude/Codex) for navigation and review; change authored and understood by me.